<template>
  <view class="container">
    <!-- 动态加载页面内容 -->
    <view v-if="currentIndex === 0">
      <home />
    </view>
    <view v-else-if="currentIndex === 1">
      <!-- <category /> -->
	  
    </view>
    <view v-else-if="currentIndex === 3">
      <cart />
    </view>
    <view v-else-if="currentIndex === 4">
      <user />
    </view>

    <!-- 自定义底部导航栏 -->
    <CustomTabBar @tab-change="handleTabChange" />
  </view>
</template>

<script>
import CustomTabBar from '@/components/CustomTabBar.vue';
import Home from '@/pages/home/home.vue';
import Category from '@/pages/category/category.vue';
import Cart from '@/pages/cart/cart.vue';
import User from '@/pages/user/user.vue';

export default {
  components: {
    CustomTabBar,
    Home,
    Category,
    Cart,
    User
  },
  data() {
    return {
      currentIndex: 0 // 当前选中的标签索引
    };
  },
  methods: {
    handleTabChange(index) {
      this.currentIndex = index;
	  if(index == 1){
		uni.navigateTo({
			url:'/pages/category/category'
		})  
	  }
    }
  }
};
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
</style>